/*
 * @Author: 卡卡 1071780426@qq.com
 * @Date: 2022-07-26 14:09:39
 * @LastEditors: 贺楠 1071780426@qq.com
 * @LastEditTime: 2024-06-18 09:07:27
 * @FilePath: \backstage\src\main.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Vue from 'vue';
import ElementUI from 'element-ui';
import '@/utils/directive/directives.js'
import common from '@/utils/date.js'
import commonJs from '@/utils/common.js'



Vue.prototype.common = common;
Vue.prototype.commonJs = commonJs;
// Vue.use(MyFun);


import iView from 'iview';

Vue.use(iView)



import VueAMap from 'vue-amap'

Vue.use(VueAMap)


import JsonExcel from 'vue-json-excel'

Vue.component('downloadExcel', JsonExcel)
// //引入组件
import {
  Message
} from 'element-ui';
ElementUI.Dialog.props.closeOnClickModal.default = false
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue';
import Fragment from 'vue-fragment' //包main
Vue.use(Fragment.Plugin)
Vue.use(ElementUI);

// //注意：这里使用的$message,所以在使用时候也是this.$message
Vue.prototype.$message = function (msg) {
  return Message({
    message: msg,
    duration: 1000
  });
};
// 分别对success、warning和error等样式进行设置
Vue.prototype.$message.success = function (msg) {
  return Message.success({
    message: msg,
    duration: 1000
  });
};
Vue.prototype.$message.warning = function (msg) {
  return Message.warning({
    message: msg,
    duration: 1000
  });
};
Vue.prototype.$message.error = function (msg) {
  return Message.error({
    message: msg,
    duration: 1000
  });
};

import router from './router'
import store from './store'
// import Nprogress from 'nprogress'
// import 'nprogress/nprogress.css'
// 图片插件
import Viewer from "v-viewer";
import "viewerjs/dist/viewer.css";
// 引入 echarts
import * as echarts from 'echarts'
import 'echarts-liquidfill'
import 'echarts-gl'
Vue.prototype.$echarts = echarts
Vue.use(Viewer, {
  defaultOptions: {
    zIndex: 9999
  }
});
Viewer.setDefaults({
  // toolbar: false,
  Options: {
    inline: true, // 是否启动inline模式
    button: true, // 是否显示右上角关闭按钮
    navbar: true, // 是否显示缩略图导航
    title: false, // 是否显示当前图片的标题
    toolbar: false, // 是否显示工具栏
    tooltip: true, // 是否显示缩放百分比
    movable: true, // 图片是否可移动
    zoomable: true, // 图片是否可缩放
    rotatable: true, // 图片是否可旋转
    scalable: true, // 图片是翻转
    transition: true, // 是否使用css3过渡
    fullscreen: true, // 播放时是否全屏
    keyboard: true, // 是否支持键盘
    url: "data-source" // 设置大图片的url
  }
});

// import VueCodeMirror from 'vue-codemirror'
// import 'codemirror/lib/codemirror.css'
// Vue.use(VueCodeMirror)

// 图片插件
// 加密
import md5 from 'js-md5'
Vue.prototype.$md5 = md5
import './assets/font/iconfont.css'
// 引入公共样式
import "./assets/css/global.css";
import "./assets/css/theme.css";

// 省市区
import VDistpicker from 'v-distpicker'
Vue.component('v-distpicker', VDistpicker)
// 图表自适应
Vue.prototype.$echartsResize = function (ref) {
  window.addEventListener("resize", function () {
    ref.resize();
  });
};








// rem 布局
function setRem() {
  var whdef = 100 / 1920; // 表示1920的设计图,使用100PX的默认值
  var bodyWidth = document.body.clientWidth; // 当前窗口的宽度
  var rem = bodyWidth * whdef; // 以默认比例值乘以当前窗口宽度,得到该宽度下的相应FONT-SIZE值
  document.getElementsByTagName("html")[0].style.fontSize = rem + "px";
}
window.addEventListener("load", setRem);
window.addEventListener("resize", setRem);
// Vue.prototype.$echarts = window.echarts;
// 接口头部
// 山丹 8054
import axios from "axios";
var url = "http://192.168.0.22:8081/concreteScreen/Base/"
Vue.prototype.$url = url
axios.defaults.baseURL = "http://192.168.0.22:8081/concreteScreen/Base/"

// 添加请求拦截器，在请求头中加token
axios.interceptors.request.use(
  config => {
    //判断token是否存在window.sessionStorage.setItem
    if (sessionStorage.getItem("yjSmart-token")) {
      // 在请求头中添加token
      config.headers.token = sessionStorage.getItem("yjSmart-token");
    }
    // Nprogress.start()
    return config;
  },
  error => {
    return Promise.reject(error);
  });
axios.interceptors.response.use(config => {
  // Nprogress.done()
  return config
})

Vue.prototype.$http = axios;
// console.log = function () {}

Vue.config.productionTip = false
// import VueRouter from 'vue-router'
// Vue.use(VueRouter)
// // 解决报错 此方法只针对VueRouter3.0以上
// const originalPush = VueRouter.prototype.push
// VueRouter.prototype.push = function push(location) {
//   return originalPush.call(this, location).catch(err => err)
// }
import VueRouter from 'vue-router'
Vue.use(VueRouter)
// 解决报错 此方法只针对VueRouter3.0以上
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


new Vue({
  router,
  store,
  // ViewUIPlus,
  mounted() {
    setRem();
  },
  el: '#app',
  render: h => h(App)
}).$mount('#app')